<template>
  <div class="leftNav-box">
    <el-menu mode="vertical" :default-active="activeIndex" background-color="#313444" text-color="#9C9EAF" active-text-color="#00B2A9">
      <router-link :to="item.link" v-for="(item, index) in dataList" :key="index">
        <el-menu-item :index="item.index">
          <span slot="title">{{ item.linkName }}</span>
        </el-menu-item>
      </router-link>
      <router-link v-if="isShowErrorReporting" to="/errorReporting">
        <el-menu-item :index="dataList.length+1">
          <span slot="title"> 错误报告</span>
        </el-menu-item>
      </router-link>
    </el-menu>
  </div>

</template>
<script>
export default {
  name: "leftNav",
  computed: {
    // 需要控制权限
    isShowErrorReporting() {
      const myPower =
        this.$store.state.activityId.myPower == 1 ||
        this.$store.state.activityId.myPower == 2;
      return myPower;
    }
  },
  data() {
    return {
      activeIndex: "1",
      dataList: [
        {
          index: "1",
          link: "/allTicket",
          linkName: "所有门票"
        },
        {
          index: "2",
          link: "/allOrder",
          linkName: "所有订单"
        },
        {
          index: "3",
          link: "/groupBuying",
          linkName: "团购票"
        },
        {
          index: "4",
          link: "/recycleBin",
          linkName: "回收站"
        },
        {
          index: "5",
          link: "/invoiceM",
          linkName: "纸质发票"
        },
        {
          index: "6",
          link: "/invoiceEtc",
          linkName: "电子发票"
        },
        {
          index: "7",
          link: "/operatRecord",
          linkName: "操作日志"
        }
      ]
    };
  },
  created() {
    this.sureThisPage();
  },
  // 确定当前页面
  methods: {
    sureThisPage() {
      if (this.activeIndex == "1") {
        this.$store.state.router.thisRouterName = "/allTicket";
      }
      this.$openPage(this.$store.state.router.thisRouterName);
    }
  }
};
</script>
  <style scoped>
.leftNav-box {
  position: fixed;
  left: 0px;
  top: 0px;
  width: 126px;
  min-width: 126px;
  height: 100%;
  padding-top: 79px;
  background: #313444;
  z-index: 97;
}
.leftNav-box > ul {
  border: none;
}
</style>